package cn.net.sinodata.common.core.enums;

import cn.net.sinodata.common.core.domain.R;

public enum MsgParseHandlerTypeEnum {
    XML("XML", "XML报文格式"),
    JSON("JOSN","JSON报文格式");

    public final String code;
    public final String msg;

    MsgParseHandlerTypeEnum(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    /**
     * 通过code获取对应实例
     * @param code
     * @return
     */
    public static MsgParseHandlerTypeEnum getInstance(String code) {
        for (MsgParseHandlerTypeEnum value : values()) {
            if (value.equals(code)) {
                return value;
            }
        }
        return null;
    }

    /**
     * 自定义equals
     * @param code
     * @return
     */
    public boolean equalsCode(String code) {
        return this.code.equals(code) ? true : false;
    }

    @Override
    public String toString() {
        return "[code="+code+",msg="+msg+"]";
    }

}
